NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

3    
4    
5    DM "log; clear; ";
6    DM 'odsresults; clear';
7    options noserror;
8    
9    %global projectrootdirectory;
10   %let projectrootdirectory=C:/Users/hpham13/Projects/mf_activism/empirical;
11   
12   *Creates your local Libraries;
13   libname rawdata "&projectrootdirectory./0_input/original";
NOTE: Libref RAWDATA was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\Projects\mf_activism\empirical\0_input\original
14   libname rawdata2 "&projectrootdirectory./0_input/original/finaldatadepvars";
NOTE: Libref RAWDATA2 was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: 
      C:\Users\hpham13\Projects\mf_activism\empirical\0_input\original\finaldatadepvars
15   libname save "&projectrootdirectory./0_input/final";
NOTE: Libref SAVE was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\Projects\mf_activism\empirical\0_input\final
16   
17   %let datadirectory= C:/Users/hpham13/data ;
18   
19   libname lnk "&datadirectory./Linking_tables/";
NOTE: Libref LNK was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\data\Linking_tables
20   libname ceo "&datadirectory./ceo/";
NOTE: Libref CEO was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\data\ceo
21   libname activism "&datadirectory./activism/" ;
NOTE: Libref ACTIVISM was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\data\activism
22   libname comp "&datadirectory./compustat/fundq/";
NOTE: Libref COMP was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\data\compustat\fundq
23   libname compa "&datadirectory./compustat/funda/";
NOTE: Libref COMPA was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\data\compustat\funda
24   libname ibes "&datadirectory./IBES";
NOTE: Libref IBES was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\data\IBES
25   
26   * include some macros;
27   %include "&datadirectory./utils/do_over.sas";
334  %include "&datadirectory./utils/ff48.sas";
406  %include "&datadirectory./utils/ff49.sas";
479  %include "&datadirectory./utils/ff12.sas";
518  %include "&datadirectory./utils/winsorize.sas";
606   %include "&datadirectory./utils/lags.sas";
785   
786   
787   /* ************************************************************************ */
788   /* ***********************  PART 1: IMPORT DATA  ************************** */
789   /* ************************************************************************ */
790   %let fname  = 111624_mff_1;         * cutoff 1.0% ;
791   %let fname2 = 111624_mff_2;         * cutoff 2.0% ;
792   %let fname3 = 111624_mff_3;         * cutoff 3.0% ;
793   %let fname4 = 111624_mff_5;         * cutoff 5.0% ;
794   %let fname5 = 111624_mff_stdized;   * cutoff 1.0% ;
795   %let fname6 = 111624_mff_1n;        * cutoff 1.0% Topx ;
796   %let fname7 = 111624_mff_4;         * cutoff 4.0% ;
797   
798   * cutoff 1%;
799   data stockpick; set rawdata2.stkpick&fname.;
800       label relstkpick1="RelInformedTrade cutoff 1%" ;
801   run;

NOTE: There were 240430 observations read from the data set RAWDATA2.STKPICK111624_MFF_1.
NOTE: The data set WORK.STOCKPICK has 240430 observations and 26 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.04 seconds
      

802   
803   * cutoff 2%;
804   data stockpick2; set rawdata2.stkpick&fname2.;
805       keep   gvkey rdq relstkpick1 avg_stkpick1_all stkpick1_large stkpick1_small mfor
805 ! numinstlarge  avgmforlarge summforlarge numinstsmall avgmforsmall summforsmall ;
806       label  relstkpick1="RelInformedTrade cutoff 2%" ;
807       rename relstkpick1      = relstkpick1_2pct;
808       rename avg_stkpick1_all = avg_stkpick1_all_2pct;
809       rename stkpick1_large   = stkpick1_large_2pct;
810       rename stkpick1_small   = stkpick1_small_2pct;
811       rename mfor = mfor_2pct;
812       rename numinstlarge = numinstlarge_2pct;
813       rename avgmforlarge = avgmforlarge_2pct;
814       rename summforlarge = summforlarge_2pct;
815       rename numinstsmall = numinstsmall_2pct;
816       rename avgmforsmall = avgmforsmall_2pct;
817       rename summforsmall = summforsmall_2pct;
818   run;

NOTE: There were 185704 observations read from the data set RAWDATA2.STKPICK111624_MFF_2.
NOTE: The data set WORK.STOCKPICK2 has 185704 observations and 13 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

819   
820   * cutoff 3%;
821   data stockpick3; set rawdata2.stkpick&fname3.;
822       keep   gvkey rdq relstkpick1 avg_stkpick1_all stkpick1_large stkpick1_small mfor
822 ! numinstlarge  avgmforlarge summforlarge numinstsmall avgmforsmall summforsmall;
823       label  relstkpick1="RelInformedTrade cutoff 3%" ;
824       rename relstkpick1      = relstkpick1_3pct;
825       rename avg_stkpick1_all = avg_stkpick1_all_3pct;
826       rename stkpick1_large   = stkpick1_large_3pct;
827       rename stkpick1_small   = stkpick1_small_3pct;
828       rename mfor = mfor_3pct;
829       rename numinstlarge = numinstlarge_3pct;
830       rename avgmforlarge = avgmforlarge_3pct;
831       rename summforlarge = summforlarge_3pct;
832       rename numinstsmall = numinstsmall_3pct;
833       rename avgmforsmall = avgmforsmall_3pct;
834       rename summforsmall = summforsmall_3pct;
835   run;

NOTE: There were 138852 observations read from the data set RAWDATA2.STKPICK111624_MFF_3.
NOTE: The data set WORK.STOCKPICK3 has 138852 observations and 13 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

836   
837   * cutoff 5%;
838   data stockpick4; set rawdata2.stkpick&fname4.;
839       keep   gvkey rdq relstkpick1 avg_stkpick1_all stkpick1_large stkpick1_small mfor
839 ! numinstlarge  avgmforlarge summforlarge numinstsmall avgmforsmall summforsmall ;
840       label  relstkpick1="RelInformedTrade cutoff 5%" ;
841       rename relstkpick1      = relstkpick1_5pct;
842       rename avg_stkpick1_all = avg_stkpick1_all_5pct;
843       rename stkpick1_large   = stkpick1_large_5pct;
844       rename stkpick1_small   = stkpick1_small_5pct;
845       rename mfor = mfor_5pct;
846       rename numinstlarge = numinstlarge_5pct;
847       rename avgmforlarge = avgmforlarge_5pct;
848       rename summforlarge = summforlarge_5pct;
849       rename numinstsmall = numinstsmall_5pct;
850       rename avgmforsmall = avgmforsmall_5pct;
851       rename summforsmall = summforsmall_5pct;
852   run;

NOTE: There were 62079 observations read from the data set RAWDATA2.STKPICK111624_MFF_5.
NOTE: The data set WORK.STOCKPICK4 has 62079 observations and 13 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

853   proc sort nodupkey; by gvkey rdq; run;

NOTE: There were 62079 observations read from the data set WORK.STOCKPICK4.
NOTE: 334 observations with duplicate key values were deleted.
NOTE: The data set WORK.STOCKPICK4 has 61745 observations and 13 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

854   
855   * Standardized Informed Trade;
856   data stockpick5; set rawdata2.stkpick&fname5.;
857       keep  gvkey rdq relstkpick4 avg_stkpick4_all stkpick4_large stkpick4_small ;
858       label relstkpick4="RelInformedTrade Stdized" ;
859   run;

NOTE: There were 240430 observations read from the data set RAWDATA2.STKPICK111624_MFF_STDIZED.
NOTE: The data set WORK.STOCKPICK5 has 240430 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

860   proc sort nodupkey; by gvkey rdq; run;

NOTE: There were 240430 observations read from the data set WORK.STOCKPICK5.
NOTE: 1887 observations with duplicate key values were deleted.
NOTE: The data set WORK.STOCKPICK5 has 238543 observations and 6 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.03 seconds
      cpu time            0.06 seconds
      

861   
862   * Add TopX ;
863   data stockpick6; set rawdata2.stkpick&fname6.;
864       keep  gvkey rdq MFOR_top1 MFOR_top2 MFOR_top3 MFOR_top4 MFOR_top5 MFOR_top1_cut
864 ! MFOR_top2_cut MFOR_top3_cut MFOR_top4_cut MFOR_top5_cut;
865   run;

NOTE: There were 240430 observations read from the data set RAWDATA2.STKPICK111624_MFF_1N.
NOTE: The data set WORK.STOCKPICK6 has 240430 observations and 12 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      

866   proc sort nodupkey; by gvkey rdq; run;

NOTE: There were 240430 observations read from the data set WORK.STOCKPICK6.
NOTE: 1887 observations with duplicate key values were deleted.
NOTE: The data set WORK.STOCKPICK6 has 238543 observations and 12 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.04 seconds
      cpu time            0.06 seconds
      

867   
868   * cutoff 4%;
869   data stockpick7; set rawdata2.stkpick&fname7.;
870       keep   gvkey rdq relstkpick1 avg_stkpick1_all stkpick1_large stkpick1_small /*mfor*/
870 ! numinstlarge  avgmforlarge summforlarge numinstsmall avgmforsmall summforsmall;
871       label  relstkpick1="RelInformedTrade cutoff 4%" ;
872       rename relstkpick1      = relstkpick1_4pct;
873       rename avg_stkpick1_all = avg_stkpick1_all_4pct;
874       rename stkpick1_large   = stkpick1_large_4pct;
875       rename stkpick1_small   = stkpick1_small_4pct;
876       *rename mfor = mfor_4pct;
877       rename numinstlarge = numinstlarge_4pct;
878       rename avgmforlarge = avgmforlarge_4pct;
879       rename summforlarge = summforlarge_4pct;
880       rename numinstsmall = numinstsmall_4pct;
881       rename avgmforsmall = avgmforsmall_4pct;
882       rename summforsmall = summforsmall_4pct;
883   run;

NOTE: There were 99450 observations read from the data set RAWDATA2.STKPICK111624_MFF_4.
NOTE: The data set WORK.STOCKPICK7 has 99450 observations and 12 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

884   proc sort nodupkey; by gvkey rdq; run;

NOTE: There were 99450 observations read from the data set WORK.STOCKPICK7.
NOTE: 532 observations with duplicate key values were deleted.
NOTE: The data set WORK.STOCKPICK7 has 98918 observations and 12 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      

885   
886   * Merge datasets;
887   proc sql;
888       create table stockpick as
889       select a.*, b.*, c.*,d.*,e.*,f.*,g.*
890       from stockpick as a
891       left join stockpick2 as b on a.gvkey=b.gvkey and a.rdq=b.rdq
892       left join stockpick3 as c on a.gvkey=c.gvkey and a.rdq=c.rdq
893       left join stockpick4 as d on a.gvkey=d.gvkey and a.rdq=d.rdq
894       left join stockpick5 as e on a.gvkey=e.gvkey and a.rdq=e.rdq
895       left join stockpick6 as f on a.gvkey=f.gvkey and a.rdq=f.rdq
896       left join stockpick7 as g on a.gvkey=g.gvkey and a.rdq=g.rdq ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.STOCKPICK.
WARNING: Variable rdq already exists on file WORK.STOCKPICK.
WARNING: Variable gvkey already exists on file WORK.STOCKPICK.
WARNING: Variable rdq already exists on file WORK.STOCKPICK.
WARNING: Variable gvkey already exists on file WORK.STOCKPICK.
WARNING: Variable rdq already exists on file WORK.STOCKPICK.
WARNING: Variable gvkey already exists on file WORK.STOCKPICK.
WARNING: Variable rdq already exists on file WORK.STOCKPICK.
WARNING: Variable gvkey already exists on file WORK.STOCKPICK.
WARNING: Variable rdq already exists on file WORK.STOCKPICK.
WARNING: Variable gvkey already exists on file WORK.STOCKPICK.
WARNING: Variable rdq already exists on file WORK.STOCKPICK.
NOTE: Table WORK.STOCKPICK created, with 246752 rows and 83 columns.

897   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.65 seconds
      cpu time            0.73 seconds
      

898   
899   * drop unneccessary vars;
900   data stockpick; set stockpick;
901       drop mfor mfor_2pct mfor_3pct mfor_5pct;
902   run;

NOTE: There were 246752 observations read from the data set WORK.STOCKPICK.
NOTE: The data set WORK.STOCKPICK has 246752 observations and 79 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.07 seconds
      

903   
904   data stockpick; set stockpick;
905       format  relstkpick1 relstkpick1_2pct relstkpick1_3pct relstkpick1_5pct
906               relstkpick2 stkpick1 stkpick2 avg_stkpick1_all avg_stkpick2_all stkpick1_Large
906 ! stkpick1_Small comma8.5;
907   run;

NOTE: There were 246752 observations read from the data set WORK.STOCKPICK.
NOTE: The data set WORK.STOCKPICK has 246752 observations and 79 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.07 seconds
      

908   proc sort nodupkey; by gvkey rdq; run;

NOTE: There were 246752 observations read from the data set WORK.STOCKPICK.
NOTE: 8209 observations with duplicate key values were deleted.
NOTE: The data set WORK.STOCKPICK has 238543 observations and 79 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.13 seconds
      cpu time            0.18 seconds
      

909   
910   /* 2. merge stacked data and others */
911   data stacked_data; set rawdata.stacked_data_111624; run;

NOTE: There were 50730 observations read from the data set RAWDATA.STACKED_DATA_111624.
NOTE: The data set WORK.STACKED_DATA has 50730 observations and 52 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

912   
913   * make the cohort year;
914   data stacked_data; set stacked_data;
915       if qd_rel = 0 then _cohort_y = fyearq; else _cohort_y = 0;
916   run;

NOTE: There were 50730 observations read from the data set WORK.STACKED_DATA.
NOTE: The data set WORK.STACKED_DATA has 50730 observations and 53 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

917   proc sql;
918       create table stacked_data as
919       select *, max(_cohort_y) as cohort_y label='Cohort Year'
920       from stacked_data
921       group by cid ;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.STACKED_DATA created, with 50730 rows and 54 columns.

922   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.04 seconds
      cpu time            0.06 seconds
      

923   data stacked_data; set stacked_data;
924       drop _cohort_y ;
925   run;

NOTE: There were 50730 observations read from the data set WORK.STACKED_DATA.
NOTE: The data set WORK.STACKED_DATA has 50730 observations and 53 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

926   proc sort data=stacked_data; by cid pairid treated qd_rel; run;

NOTE: There were 50730 observations read from the data set WORK.STACKED_DATA.
NOTE: The data set WORK.STACKED_DATA has 50730 observations and 53 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      

927   
928   /* Activism campaigns data */
929   data pilot; set activism.ca_details_95_pilot; run;

NOTE: There were 9262 observations read from the data set ACTIVISM.CA_DETAILS_95_PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 147 variables.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.06 seconds
      

930   proc sort data=pilot nodupkey; by  gvkey CAMPAIGN_ID ; run;

NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.PILOT has 9262 observations and 147 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.11 seconds
      cpu time            0.11 seconds
      

931   
932   *check if two campaigns happens during the period of 8 quarters ;
933   proc sort data=pilot;
934       by gvkey ANNOUNCE_DATE;
935   run;

NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 147 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.10 seconds
      cpu time            0.10 seconds
      

936   data pilot; set pilot;
937       by gvkey ;
938       ANNOUNCE_DATE_l = lag(ANNOUNCE_DATE);
939       if first.gvkey then ANNOUNCE_DATE_l=.;
940       format ANNOUNCE_DATE_l YYMMDD10. ;
941       * count the number of quarters;
942       days_diff = intck('day', ANNOUNCE_DATE_l, ANNOUNCE_DATE);
943       if ANNOUNCE_DATE_l = . then days_diff = . ;
944       if days_diff ne . then quarter_diff = days_diff/30 ;
945           else quarter_diff = . ;
946       format quarter_diff comma8.1;
947   run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      4328 at 942:17   
NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 150 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.07 seconds
      

948   proc sort data=pilot out=pilot;
949       by gvkey descending ANNOUNCE_DATE;
950   run;

NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 150 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.10 seconds
      cpu time            0.09 seconds
      

951   
952   data pilot;
953       set pilot;
954       by gvkey;
955       retain ANNOUNCE_DATE_f;
956       if first.gvkey then ANNOUNCE_DATE_f = .;
957       ANNOUNCE_DATE_f = lag(ANNOUNCE_DATE);
958       if first.gvkey then ANNOUNCE_DATE_f = .;
959       output;
960   run;

NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 151 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.06 seconds
      

961   
962   data pilot;
963       set pilot;
964       format ANNOUNCE_DATE_f YYMMDD10. ;
965       * count the number of quarters;
966       days_diff_2 = intck('day', ANNOUNCE_DATE, ANNOUNCE_DATE_f);
967       if ANNOUNCE_DATE = . then days_diff_2 = . ;
968       if days_diff_2 ne . then quarter_diff_2 = days_diff_2/30 ;
969           else quarter_diff_2 = . ;
970       format quarter_diff_2 comma8.1;
971   run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      4328 at 966:19   
NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 153 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.07 seconds
      

972   proc sort data=pilot out=pilot;
973       by gvkey ANNOUNCE_DATE;
974   run;

NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 153 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.10 seconds
      cpu time            0.10 seconds
      

975   
976   data pilot; set pilot;
977       * count the number of days ;
978       duration  = intck('day', ANNOUNCE_DATE, MEETING_DATE)+1 ;
979       duration2 = intck('day', ANNOUNCE_DATE, END_DATE)+1;
980       duration3 = intck('day', FILING_DATE, MEETING_DATE)+1  ;
981       label duration  = "Ndays btw Announce_date and Meeting_date";
982       label duration2 = "Ndays btw Announce_date and End_date";
983       label duration3 = "Ndays btw Filing_date and Meeting_date";
984   run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      5819 at 978:17   5819 at 978:58   1412 at 979:17   1412 at 979:54   5822 at 980:17
      5822 at 980:56   
NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 156 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.07 seconds
      

985   
986   proc sql;
987       create table pilot as
988       select *, median(duration) as med_duration, median(duration2) as med_duration2
989       from pilot
990       group by year(ANNOUNCE_DATE)
991       order by gvkey, ANNOUNCE_DATE;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.PILOT created, with 9262 rows and 158 columns.

992   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.23 seconds
      cpu time            0.28 seconds
      

993   
994   * other activism vars;
995   data sharkwatch;set activism.tohai_activists_12032023;run;

NOTE: There were 3023 observations read from the data set ACTIVISM.TOHAI_ACTIVISTS_12032023.
NOTE: The data set WORK.SHARKWATCH has 3023 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

996   proc sort data=sharkwatch nodupkey; by CAMPAIGN_ID; run;

NOTE: There were 3023 observations read from the data set WORK.SHARKWATCH.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.SHARKWATCH has 3023 observations and 5 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

997   
998   * Activist prior experience;
999   data activist_prior_exp;set rawdata.activist_prior_exp;run;

NOTE: There were 2110 observations read from the data set RAWDATA.ACTIVIST_PRIOR_EXP.
NOTE: The data set WORK.ACTIVIST_PRIOR_EXP has 2110 observations and 21 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1000  %let qd = (year(ANNOUNCE_DATE)*4  + qtr(ANNOUNCE_DATE)  - 1925*4);
1001  data activist_prior_exp; set activist_prior_exp ;
1002      if ANNOUNCE_DATE ne . then do ;
1003          qd = &qd;
1004      end;
1005  run;

NOTE: There were 2110 observations read from the data set WORK.ACTIVIST_PRIOR_EXP.
NOTE: The data set WORK.ACTIVIST_PRIOR_EXP has 2110 observations and 21 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1006  proc sort data=activist_prior_exp nodupkey; by gvkey year qd; run;

NOTE: There were 2110 observations read from the data set WORK.ACTIVIST_PRIOR_EXP.
NOTE: 227 observations with duplicate key values were deleted.
NOTE: The data set WORK.ACTIVIST_PRIOR_EXP has 1883 observations and 21 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1007  
1008  /* Merge data*/
1009  proc sql;
1010      create table stacked_data2 as
1011      select  a.*, b.*, c.*, d.prior_exp,
1012              d.mean_prior_exp_sic2, d.med_prior_exp_sic2,
1013              d.med_NUMBER_CAMPAIGNS, d.mean_NUMBER_CAMPAIGNS,
1014              d.med_ACTIVIST_THREAT_RATING, d.mean_ACTIVIST_THREAT_RATING
1015      from    stacked_data as a left join pilot as b
1016      on      a.gvkey=b.gvkey and
1017              a.FACTSET_ENTITY_ID=b.FACTSET_ENTITY_ID and
1018              a.CAMPAIGN_ID=b.CAMPAIGN_ID
1019      left join sharkwatch as c
1020      on      a.CAMPAIGN_ID=c.CAMPAIGN_ID
1021      left join activist_prior_exp as d
1022      on      a.gvkey=d.gvkey and a.qd=d.qd ;
WARNING: Variable CAMPAIGN_ID already exists on file WORK.STACKED_DATA2.
WARNING: Variable ANNOUNCE_DATE already exists on file WORK.STACKED_DATA2.
WARNING: Variable FILING_DATE already exists on file WORK.STACKED_DATA2.
WARNING: Variable END_DATE already exists on file WORK.STACKED_DATA2.
WARNING: Variable FACTSET_ENTITY_ID already exists on file WORK.STACKED_DATA2.
WARNING: Variable ENTITY_PROPER_NAME already exists on file WORK.STACKED_DATA2.
WARNING: Variable gvkey already exists on file WORK.STACKED_DATA2.
WARNING: Variable CAMPAIGN_ID already exists on file WORK.STACKED_DATA2.
NOTE: Table WORK.STACKED_DATA2 created, with 50730 rows and 215 columns.

1023  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.40 seconds
      cpu time            1.78 seconds
      

1024  proc sort data=stacked_data2 nodupkey; by cID PairID treated qd_rel ; run;

NOTE: There were 50730 observations read from the data set WORK.STACKED_DATA2.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.STACKED_DATA2 has 50730 observations and 215 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.57 seconds
      cpu time            0.56 seconds
      

1025  
1026  * create the SIC2 ;
1027  data stacked_data2;
1028      set stacked_data2;
1029      sic_num = input(sic, 8.);
1030      sic2 = floor(sic/100);
1031  run;

NOTE: Character values have been converted to numeric values at the places given by: 
      (Line):(Column).
      1030:18   
NOTE: There were 50730 observations read from the data set WORK.STACKED_DATA2.
NOTE: The data set WORK.STACKED_DATA2 has 50730 observations and 217 variables.
NOTE: DATA statement used (Total process time):
      real time           0.38 seconds
      cpu time            0.39 seconds
      

1032  
1033  * count the number of campaigns per sic2-year ;
1034  proc sql;
1035      create table stacked_data2 as
1036      select
1037          a.*, b.number_campaigns_ind, b.avg_campaigns_ind, b.med_campaigns_ind,
1037! b.sd_campaigns_ind,
1038          b.med_activist_threat_rating, b.sum_activist_threat_rating,
1038! b.avg_activist_threat_rating
1039      from stacked_data2 as a
1040      left join (
1041      select distinct CAMPAIGN_ID, sic2, year
1042          , sum( number_campaigns) as number_campaigns_ind label="N campaigns (industry)"
1043          , mean( number_campaigns) as avg_campaigns_ind format comma8.3
1044          , median( number_campaigns) as med_campaigns_ind format comma8.2
1045          , std( number_campaigns) as sd_campaigns_ind format comma8.2
1046          , median(activist_threat_rating) as med_activist_threat_rating format comma8.2
1047          , avg(activist_threat_rating) as avg_activist_threat_rating format comma8.2
1048          , sum(activist_threat_rating) as sum_activist_threat_rating format comma8.2
1049          from stacked_data2
1050          group by sic2, year
1051          having number_campaigns ne . and activist_threat_rating ne .
1052          ) as b
1053      on  a.CAMPAIGN_ID=b.CAMPAIGN_ID and
1054          a.sic2=b.sic2 and
1055          a.year=b.year  ;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable med_activist_threat_rating already exists on file WORK.STACKED_DATA2.
NOTE: Table WORK.STACKED_DATA2 created, with 50730 rows and 223 columns.

1056  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.22 seconds
      cpu time            1.37 seconds
      

1057  
1058  * Merge with informtedtradegap data;
1059  proc sql;
1060      create table Analysis as
1061      select  a.*, b.*
1062      from    stacked_data2 as a left join stockpick as b
1063      on      a.gvkey=b.gvkey and a.rdq=b.rdq ;
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
WARNING: Variable datadate already exists on file WORK.ANALYSIS.
WARNING: Variable rdq already exists on file WORK.ANALYSIS.
WARNING: Variable qd already exists on file WORK.ANALYSIS.
WARNING: Variable year already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 50730 rows and 297 columns.

1064  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.98 seconds
      cpu time            1.20 seconds
      

1065  proc sort data=Analysis nodupkey; by cID PairID treated gvkey datadate; run;

NOTE: There were 50730 observations read from the data set WORK.ANALYSIS.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.ANALYSIS has 50730 observations and 297 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.61 seconds
      cpu time            0.60 seconds
      

1066  
1067  
1068  /* ************************************************************************ */
1069  /* ********************  PART 2: MERGE FUNDQ, FUNDA  ********************** */
1070  /* ************************************************************************ */
1071  data fundq_clean;
1072      set rawdata.comp_fundq_clean;
1073      keep gvkey rdq datadate fyearq fyr fqtr be /*me*/ bd ppegtq PnI saleq to dlttq dlcq
1074      oibdpq oiadpq pm ic tacq revq drevq drevadjq ppeq roaq roaq_lag1 me ml bm
1075      atq_lag1 saleq_lag1 rectq_lag1 ibq ibq_lag1 size size_l lvrg_l lvrg seqq ltq niq niq_l
1075! ;
1076      if atq > 0 and atq_lag1 > 0 ;
1077      size   = log(atq);
1078      size_l = log(atq_lag1);
1079      lvrg_l = bd/atq_lag1;
1080      lvrg   = dlttq/atq;
1081      if lvrg eq . then lvrg = 0 ;
1082  run;

WARNING: The variable niq_l in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      227702 at 1079:16   8651 at 1080:19     
NOTE: There were 1125340 observations read from the data set RAWDATA.COMP_FUNDQ_CLEAN.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 40 variables.
NOTE: DATA statement used (Total process time):
      real time           0.27 seconds
      cpu time            0.28 seconds
      

1083  proc sort data=fundq_clean nodupkey; by gvkey datadate; run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 40 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.28 seconds
      cpu time            0.40 seconds
      

1084  %let winsVars2 = saleq revq ;
1085  %winsor(dsetin=work.fundq_clean, dsetout=work.fundq_clean, byvar=fyearq, vars=&winsVars2,
1085! type=winsor, pctl=1 99);

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: The data set WORK.XTEMP has 1012247 observations and 40 variables.
NOTE: DATA statement used (Total process time):
      real time           0.16 seconds
      cpu time            0.15 seconds
      


NOTE: There were 1012247 observations read from the data set WORK.XTEMP.
NOTE: The data set WORK.XTEMP has 1012247 observations and 40 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.27 seconds
      cpu time            0.50 seconds
      

NOTE: Writing HTML Body file: sashtml.htm

NOTE: The data set WORK.XTEMP_PCTL has 30 observations and 5 variables.
NOTE: PROCEDURE UNIVARIATE used (Total process time):
      real time           1.07 seconds
      cpu time            0.92 seconds
      


WARNING: The variable xbyvar in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 1012247 observations read from the data set WORK.XTEMP.
NOTE: There were 30 observations read from the data set WORK.XTEMP_PCTL.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 40 variables.
NOTE: DATA statement used (Total process time):
      real time           0.24 seconds
      cpu time            0.23 seconds
      

1086  
1087  * get more fundq vars;
1088  data fundq_add; set comp.fundq_1950_2021;
1089      keep gvkey datadate intanq ;
1090      where datadate>'01JAN1990'd;
1091  run;

NOTE: There were 1441077 observations read from the data set COMP.FUNDQ_1950_2021.
      WHERE datadate>'01JAN1990'D;
NOTE: The data set WORK.FUNDQ_ADD has 1441077 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.29 seconds
      cpu time            0.29 seconds
      

1092  
1093  proc sort data=fundq_add nodupkey; by gvkey datadate; run;

NOTE: There were 1441077 observations read from the data set WORK.FUNDQ_ADD.
NOTE: 1238 observations with duplicate key values were deleted.
NOTE: The data set WORK.FUNDQ_ADD has 1439839 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.08 seconds
      cpu time            0.21 seconds
      

1094  proc sort data=fundq_clean nodupkey; by gvkey datadate; run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 40 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.27 seconds
      cpu time            0.45 seconds
      

1095  data fundq_clean;
1096      merge fundq_clean(in=a) fundq_add (in=b);
1097      by gvkey datadate;
1098      if a;
1099  run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: There were 1439839 observations read from the data set WORK.FUNDQ_ADD.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 41 variables.
NOTE: DATA statement used (Total process time):
      real time           0.28 seconds
      cpu time            0.29 seconds
      

1100  
1101  * Create calendar date of fiscal period end in Compustat extract;
1102  data fundq_clean; set fundq_clean;
1103     if (1<=fyr<=5) then date_fyend=intnx('month',mdy(fyr,1,fyearq+1),0,'end');
1104     else if (6<=fyr<=12) then date_fyend=intnx('month',mdy(fyr,1,fyearq),0,'end');
1105     fqenddt=intnx('month',date_fyend,-3*(4-fqtr),'end');
1106     format fqenddt date9.;
1107     drop date_fyend;
1108  run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 42 variables.
NOTE: DATA statement used (Total process time):
      real time           0.51 seconds
      cpu time            0.46 seconds
      

1109  
1110  * moving sum of quarterly loss;
1111  data fundq_clean; set fundq_clean;
1112      if niq <=0 then lossq = 1 ; else lossq = 0;
1113  run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 43 variables.
NOTE: DATA statement used (Total process time):
      real time           0.20 seconds
      cpu time            0.20 seconds
      

1114  
1115  proc sort data=fundq_clean; by gvkey datadate; run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 43 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.29 seconds
      cpu time            0.45 seconds
      

1116  proc expand data=fundq_clean out=fundq_clean;
1117      by gvkey ;
1118      id datadate;
1119      convert lossq = sum_lossq12 / transformout=(movsum 16);
1120      convert niq = ma_niq12 / transformout=(movave 16);
1121      convert ibq = sd_niq12 / transformout=(movstd 16);
1122      convert roaq = sd_roaq12 / transformout=(movstd 16);
1123  run;

WARNING: The variable niq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ibq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable roaq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=009879
WARNING: The variable niq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ibq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable roaq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=010673
WARNING: The variable niq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ibq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable roaq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=013260
WARNING: The variable niq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ibq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable roaq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=013530
WARNING: The variable niq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ibq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable roaq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=013938
WARNING: The variable niq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ibq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable roaq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=060976
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 47 variables.
NOTE: PROCEDURE EXPAND used (Total process time):
      real time           1.47 seconds
      cpu time            1.46 seconds
      

1124  
1125  data fundq_clean; set fundq_clean;
1126      drop datadate;
1127  run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 46 variables.
NOTE: DATA statement used (Total process time):
      real time           0.21 seconds
      cpu time            0.20 seconds
      

1128  
1129  * add funda vars ;
1130  data funda_clean;
1131      set rawdata.comp_funda_clean2020;
1132      if at>0 & at_l>0;
1133      asize   = log(at);
1134      asize_l = log(at_l);
1135      bm_ann = bm;
1136      roa2 = ib_l/at_l;
1137      if ni < 0 then loss_a = 1; else loss_a = 0;
1138      where datadate ne . and at>0;
1139      label asize = "Log(AT)"
1140      asize_l = "Log(AT_l)" ;
1141  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      272 at 1136:16   
NOTE: There were 182044 observations read from the data set RAWDATA.COMP_FUNDA_CLEAN2020.
      WHERE (datadate not = .) and (at>0);
NOTE: The data set WORK.FUNDA_CLEAN has 181286 observations and 118 variables.
NOTE: DATA statement used (Total process time):
      real time           0.11 seconds
      cpu time            0.10 seconds
      

1142  proc sort data=funda_clean nodupkey ; by gvkey fyear; run;

NOTE: There were 181286 observations read from the data set WORK.FUNDA_CLEAN.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.FUNDA_CLEAN has 181286 observations and 118 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.17 seconds
      cpu time            0.18 seconds
      

1143  
1144  proc expand data=funda_clean out=funda_clean;
1145      by gvkey;
1146      id fyear;
1147      convert loss_a = sum_loss_a5 / transformout=(movsum 10);
1148      convert roa2 = ma_roa5 / transformout=(movstd 10);
1149      convert ib = ma_ni5 / transformout=(movstd 10);
1150  run;

WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=009879
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=012161
WARNING: The variable roa2 has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=013260
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=013530
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=028379
WARNING: The variable roa2 has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=030719
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=031810
WARNING: The variable roa2 has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=065561
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=065844
WARNING: The variable roa2 has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=066707
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=110320
WARNING: The variable roa2 has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=129631
WARNING: The variable roa2 has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=144564
NOTE: The data set WORK.FUNDA_CLEAN has 181286 observations and 121 variables.
NOTE: PROCEDURE EXPAND used (Total process time):
      real time           0.58 seconds
      cpu time            0.57 seconds
      

1151  
1152  * additional funda vars;
1153  data funda_add; set compa.funda_1950_2021;
1154      keep gvkey datadate intan ;
1155  run;

NOTE: There were 861623 observations read from the data set COMPA.FUNDA_1950_2021.
NOTE: The data set WORK.FUNDA_ADD has 861623 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.14 seconds
      cpu time            0.12 seconds
      

1156  proc sort data=funda_add nodupkey; by gvkey datadate; run;

NOTE: There were 861623 observations read from the data set WORK.FUNDA_ADD.
NOTE: 307572 observations with duplicate key values were deleted.
NOTE: The data set WORK.FUNDA_ADD has 554051 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.05 seconds
      cpu time            0.17 seconds
      

1157  data funda_clean;
1158      merge funda_clean(in=a) funda_add(in=b);
1159      by gvkey datadate;
1160      if a;
1161  run;

NOTE: There were 181286 observations read from the data set WORK.FUNDA_CLEAN.
NOTE: There were 554051 observations read from the data set WORK.FUNDA_ADD.
NOTE: The data set WORK.FUNDA_CLEAN has 181286 observations and 122 variables.
NOTE: DATA statement used (Total process time):
      real time           0.15 seconds
      cpu time            0.14 seconds
      

1162  
1163  *  firm age ;
1164  data funda_clean ;
1165      set funda_clean;
1166      by gvkey;
1167      if first.gvkey then
1168          firm_age=0;
1169      firm_age + 1;
1170  run;

NOTE: There were 181286 observations read from the data set WORK.FUNDA_CLEAN.
NOTE: The data set WORK.FUNDA_CLEAN has 181286 observations and 123 variables.
NOTE: DATA statement used (Total process time):
      real time           0.10 seconds
      cpu time            0.10 seconds
      

1171  proc sort data=funda_clean; by gvkey fyear;  run;

NOTE: There were 181286 observations read from the data set WORK.FUNDA_CLEAN.
NOTE: The data set WORK.FUNDA_CLEAN has 181286 observations and 123 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.15 seconds
      cpu time            0.25 seconds
      

1172  
1173  * Calculate the mean, median, and standard deviation by industry ;
1174  proc sql;
1175      create table funda_clean as
1176      select  *,
1177              mean(firm_age) as ind_mean_firm_age label="Industry mean firm age",
1178              median(firm_age) as ind_med_firm_age label="Industry median firm age",
1179              std(firm_age) as ind_std_firm_age label="Industry Std firm age"
1180      from    funda_clean
1181      group by sic2, fyear
1182      order by gvkey, fyear;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.FUNDA_CLEAN created, with 181286 rows and 126 columns.

1183  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.38 seconds
      cpu time            0.57 seconds
      

1184  
1185  data StateName;set rawdata.firmStateName;run;

NOTE: There were 41696 observations read from the data set RAWDATA.FIRMSTATENAME.
NOTE: The data set WORK.STATENAME has 41696 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1186  
1187  proc sql;
1188      create table Analysis as
1189      select  a.*,b.*,
1190              c.StateName label="Firm HQ State", c.ST label="State",
1191              d.at, d.at_l, d.sale, d.sale_l, d.ni, d.ib, d.ibc,
1192              d.firm_age, d.ind_mean_firm_age, d.ind_std_firm_age, d.ind_med_firm_age,
1193              d.revt, d.revt_l, d.ceq, d.datadate as datadate_ann, d.xrd, d.intan,
1194              d.ma_roa5, d.ma_ni5, d.sum_loss_a5
1195      from    Analysis as a
1196      left join fundq_clean as b
1197          on  a.gvkey=b.gvkey and a.rdq=b.rdq
1198      left join StateName as c
1199          on  a.gvkey=c.gvkey
1200      left join funda_clean as d
1201          on  a.gvkey=d.gvkey and a.fyearq=d.fyear ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
WARNING: Variable fyearq already exists on file WORK.ANALYSIS.
WARNING: Variable fqtr already exists on file WORK.ANALYSIS.
WARNING: Variable fyr already exists on file WORK.ANALYSIS.
WARNING: Variable rdq already exists on file WORK.ANALYSIS.
WARNING: Variable dlcq already exists on file WORK.ANALYSIS.
WARNING: Variable dlttq already exists on file WORK.ANALYSIS.
WARNING: Variable ibq already exists on file WORK.ANALYSIS.
WARNING: Variable ltq already exists on file WORK.ANALYSIS.
WARNING: Variable niq already exists on file WORK.ANALYSIS.
WARNING: Variable oiadpq already exists on file WORK.ANALYSIS.
WARNING: Variable oibdpq already exists on file WORK.ANALYSIS.
WARNING: Variable ppegtq already exists on file WORK.ANALYSIS.
WARNING: Variable saleq already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 51532 rows and 351 columns.

1202  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           2.39 seconds
      cpu time            2.98 seconds
      

1203  
1204  proc sql;
1205      create table Analysis as
1206      select  *,
1207              max(firm_age) as firm_age2
1208      from    Analysis
1209      group by cid, gvkey, year(datadate)
1210      order by cid, pairid, gvkey, rdq;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 51532 rows and 352 columns.

1211  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.34 seconds
      cpu time            1.75 seconds
      

1212  
1213  proc sql;
1214      create table Analysis as
1215      select  *,
1216              mean(firm_age) as ind_mean_firm_age2 label="Industry mean firm age",
1217              median(firm_age) as ind_med_firm_age2 label="Industry median firm age",
1218              std(firm_age) as ind_std_firm_age2 label="Industry Std firm age"
1219      from    Analysis
1220      group by cid, sic2
1221      order by cid, pairid, gvkey, rdq;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 51532 rows and 355 columns.

1222  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.32 seconds
      cpu time            1.60 seconds
      

1223  
1224  * check calendar quarter ;
1225  data Analysis; set Analysis;
1226      calyear = year(datadate_ann);
1227      if calyear = . then calyear = year(fqenddt);
1228      calqtr = qtr(datadate);
1229  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      3568 at 1226:15   127 at 1227:35    
NOTE: There were 51532 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 51532 observations and 357 variables.
NOTE: DATA statement used (Total process time):
      real time           0.33 seconds
      cpu time            0.31 seconds
      

1230  
1231  * compute the average inst ownership over the fiscal year;
1232  proc sql;
1233      create table Analysis as
1234      select  *,
1235              avg(ior) as avg_ior label="Average Qtr IOR" format comma8.4
1236      from    Analysis
1237      group by gvkey, fyearq
1238      order by cid, gvkey, rdq;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 51532 rows and 358 columns.

1239  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.37 seconds
      cpu time            1.75 seconds
      

1240  data Analysis;
1241      retain gvkey fyearq fqtr rdq datadate ANNOUNCE_DATE treated post qd_rel cid pairid qd;
1242      set Analysis;
1243      if cmiss (of relstkpick1 ) eq 0;
1244  run;

NOTE: There were 51532 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 33915 observations and 358 variables.
NOTE: DATA statement used (Total process time):
      real time           0.27 seconds
      cpu time            0.26 seconds
      

1245  
1246  
1247  /* ************************************************************************ */
1248  * make some vars to check the number of non-missing Relstkpick ;
1249  /* ************************************************************************ */
1250  * COUNTER is a cummulative number: 0,1,2,3,4,5 ;
1251  proc sort data=Analysis; by cid gvkey post; run;

NOTE: There were 33915 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 33915 observations and 358 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.33 seconds
      cpu time            0.31 seconds
      

1252  data Analysis;
1253      set Analysis;
1254      by cID gvkey post;
1255      if first.post then COUNTER=0;
1256      COUNTER+(Relstkpick1 ne .);
1257  run;

NOTE: There were 33915 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 33915 observations and 359 variables.
NOTE: DATA statement used (Total process time):
      real time           0.22 seconds
      cpu time            0.23 seconds
      

1258  
1259  proc sql;
1260      create table Analysis as
1261      select *, max(COUNTER) as COUNTER_BY_POST
1262      from Analysis
1263      group by cID, gvkey, post
1264      order by cid, gvkey, qd_rel ;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33915 rows and 360 columns.

1265  
1266      create table Analysis as
1267      select *,
1268          min(post) as MIN_POST,
1269          max(post) as MAX_POST,
1270          min(COUNTER_BY_POST) as MIN_NOBS_PRE_POST
1271      from Analysis
1272      group by cID, gvkey
1273      order by cid, gvkey, qd_rel ;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33915 rows and 363 columns.

1274  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.43 seconds
      cpu time            1.60 seconds
      

1275  proc sort data=Analysis ; by cID PairID treated gvkey datadate; run;

NOTE: There were 33915 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 33915 observations and 363 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.34 seconds
      cpu time            0.34 seconds
      

1276  proc sort data=Analysis nodupkey; by cID treated gvkey datadate; run;

NOTE: There were 33915 observations read from the data set WORK.ANALYSIS.
NOTE: 481 observations with duplicate key values were deleted.
NOTE: The data set WORK.ANALYSIS has 33434 observations and 363 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.34 seconds
      cpu time            0.34 seconds
      

1277  
1278  * destring SIC;
1279  data Analysis;  set Analysis;   sic_num = input(sic, 8.); label sic_num="Standard Industry
1279! Classification Code"; drop sic; run;

NOTE: There were 33434 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 33434 observations and 362 variables.
NOTE: DATA statement used (Total process time):
      real time           0.22 seconds
      cpu time            0.23 seconds
      

1280  data Analysis;  set Analysis;   rename sic_num = sic; run;

NOTE: There were 33434 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 33434 observations and 362 variables.
NOTE: DATA statement used (Total process time):
      real time           0.22 seconds
      cpu time            0.20 seconds
      

1281  proc sort data=Analysis nodupkey; by cid gvkey datadate; run;

NOTE: There were 33434 observations read from the data set WORK.ANALYSIS.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.ANALYSIS has 33434 observations and 362 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.33 seconds
      cpu time            0.32 seconds
      

1282  
1283  
1284  /* ************************************************************************ */
1285  /* ***********************  PART 3: OTHER DATASET  ************************ */
1286  /* ************************************************************************ */
1287  * Analyst forecast and Analyst following;
1288  data afc; set rawdata.afc_fundq;
1289      keep gvkey fyearq datadate rdq numest lnanalys repdats ryear ;
1290      lnanalys = log(1+numest);
1291      if lnanalys ne . ;
1292      ryear = year(repdats);
1293  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      480890 at 1290:16   480890 at 1290:21   
NOTE: There were 988699 observations read from the data set RAWDATA.AFC_FUNDQ.
NOTE: The data set WORK.AFC has 507809 observations and 8 variables.
NOTE: DATA statement used (Total process time):
      real time           0.11 seconds
      cpu time            0.11 seconds
      

1294  proc sort data=afc nodupkey ; by gvkey repdats; run;

NOTE: There were 507809 observations read from the data set WORK.AFC.
NOTE: 1183 observations with duplicate key values were deleted.
NOTE: The data set WORK.AFC has 506626 observations and 8 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.06 seconds
      cpu time            0.11 seconds
      

1295  
1296  proc sql;
1297      create table afc as
1298      select  distinct gvkey, ryear, datadate,
1299              max(numest) as numest_max label="Max #Analyst (year)",
1300              max(lnanalys) as lnanalys_max label="Max #LnAnalyst (year)"
1301      from    afc
1302      group by gvkey, ryear
1303      order by gvkey, datadate;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.AFC created, with 506626 rows and 5 columns.

1304  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.17 seconds
      cpu time            0.28 seconds
      

1305  
1306  * Stock illiquidity (AIM);
1307  data aim; set rawdata.aim; run;

NOTE: There were 649518 observations read from the data set RAWDATA.AIM.
NOTE: The data set WORK.AIM has 649518 observations and 9 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      

1308  proc sort data=aim nodupkey; by gvkey datadate; run;

NOTE: There were 649518 observations read from the data set WORK.AIM.
NOTE: 374 observations with duplicate key values were deleted.
NOTE: The data set WORK.AIM has 649144 observations and 9 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.06 seconds
      cpu time            0.15 seconds
      

1309  
1310  * Price synchronicity (Morck et al 2002);
1311  data psynch ; set rawdata.pinfo_qtr_retx6d; run;

NOTE: There were 515792 observations read from the data set RAWDATA.PINFO_QTR_RETX6D.
NOTE: The data set WORK.PSYNCH has 515792 observations and 9 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      

1312  proc sort data=psynch; by gvkey fyear fqtr; run;

NOTE: There were 515792 observations read from the data set WORK.PSYNCH.
NOTE: The data set WORK.PSYNCH has 515792 observations and 9 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.05 seconds
      cpu time            0.14 seconds
      

1313  data psynch; set psynch;
1314      by gvkey fyear fqtr;
1315      if last.fqtr;
1316  run;

NOTE: There were 515792 observations read from the data set WORK.PSYNCH.
NOTE: The data set WORK.PSYNCH has 515774 observations and 9 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.04 seconds
      

1317  
1318  * the Bushee's IICLASS data;
1319  data io_class;
1320      set rawdata.io_class2022qtr;
1321      rqtr = qtr(rdate);
1322      ryear = year(rdate);
1323  run;

NOTE: There were 737259 observations read from the data set RAWDATA.IO_CLASS2022QTR.
NOTE: The data set WORK.IO_CLASS has 737259 observations and 13 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.07 seconds
      

1324  
1325  * Financial constraints;
1326  data constraints; set rawdata.constraints; run;

NOTE: There were 162789 observations read from the data set RAWDATA.CONSTRAINTS.
NOTE: The data set WORK.CONSTRAINTS has 162789 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

1327  
1328  * Opacity;
1329  data AFERR;
1330      set rawdata.AFERR;
1331      fpeyear = year(FPEDATS);
1332      drop fyear;
1333  run;

NOTE: There were 124683 observations read from the data set RAWDATA.AFERR.
NOTE: The data set WORK.AFERR has 124683 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

1334  proc sort data=AFERR nodupkey; by gvkey fpeyear; run;

NOTE: There were 124683 observations read from the data set WORK.AFERR.
NOTE: 14 observations with duplicate key values were deleted.
NOTE: The data set WORK.AFERR has 124669 observations and 14 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      

1335  data AFERR; set AFERR; drop fpeyear; run;

NOTE: There were 124669 observations read from the data set WORK.AFERR.
NOTE: The data set WORK.AFERR has 124669 observations and 13 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

1336  
1337  * Ivol quarterly;
1338  data retvol; set rawdata.retvolqtr_112824;run;

NOTE: There were 519328 observations read from the data set RAWDATA.RETVOLQTR_112824.
NOTE: The data set WORK.RETVOL has 519328 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      

1339  proc sort data=retvol nodupkey; by gvkey enddt; run;

NOTE: There were 519328 observations read from the data set WORK.RETVOL.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.RETVOL has 519328 observations and 7 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.05 seconds
      cpu time            0.14 seconds
      

1340  
1341  * abnormal trading volume ;
1342  data abvolume; set rawdata.abvolume; run;

NOTE: There were 747275 observations read from the data set RAWDATA.ABVOLUME.
NOTE: The data set WORK.ABVOLUME has 747275 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      

1343  proc sort data=abvolume nodupkey; by gvkey fyearq fqtr; run;

NOTE: There were 747275 observations read from the data set WORK.ABVOLUME.
NOTE: 29080 observations with duplicate key values were deleted.
NOTE: The data set WORK.ABVOLUME has 718195 observations and 6 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.06 seconds
      cpu time            0.12 seconds
      

1344  
1345  * CAR at meeting dates to activism data;
1346  data car_meetingdt1; set rawdata.car_meetingdt_capm_00;
1347  rename car = car_meeting00;
1348  label car = "AR[0] Meeting dt";
1349  run;

NOTE: There were 1826 observations read from the data set RAWDATA.CAR_MEETINGDT_CAPM_00.
NOTE: The data set WORK.CAR_MEETINGDT1 has 1826 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1350  proc sort data=car_meetingdt1 nodupkey; by pairid treated gvkey ANNOUNCE_DATE ; run;

NOTE: There were 1826 observations read from the data set WORK.CAR_MEETINGDT1.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.CAR_MEETINGDT1 has 1826 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1351  
1352  data car_meetingdt2; set rawdata.car_meetingdt_capm_01;
1353  rename car = car_meeting01;
1354  label car = "CAR[0+1] Meeting dt";
1355  run;

NOTE: There were 1826 observations read from the data set RAWDATA.CAR_MEETINGDT_CAPM_01.
NOTE: The data set WORK.CAR_MEETINGDT2 has 1826 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1356  proc sort data=car_meetingdt2 nodupkey; by pairid treated gvkey ANNOUNCE_DATE ; run;

NOTE: There were 1826 observations read from the data set WORK.CAR_MEETINGDT2.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.CAR_MEETINGDT2 has 1826 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1357  
1358  data car_meetingdt3; set rawdata.car_meetingdt_capm_11_round2;
1359  rename car = car_meeting11;
1360  label car = "CAR[-1+1] Meeting dt";
1361  run;

NOTE: There were 1846 observations read from the data set RAWDATA.CAR_MEETINGDT_CAPM_11_ROUND2.
NOTE: The data set WORK.CAR_MEETINGDT3 has 1846 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1362  proc sort data=car_meetingdt3 nodupkey; by pairid treated gvkey ANNOUNCE_DATE ; run;

NOTE: There were 1846 observations read from the data set WORK.CAR_MEETINGDT3.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.CAR_MEETINGDT3 has 1846 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1363  
1364  data car_meetingdt4; set rawdata.car_meetingdt_capm_17;
1365  rename car = car_meeting17;
1366  label car = "CAR[+1+7] Meeting dt";
1367  run;

NOTE: There were 1826 observations read from the data set RAWDATA.CAR_MEETINGDT_CAPM_17.
NOTE: The data set WORK.CAR_MEETINGDT4 has 1826 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1368  proc sort data=car_meetingdt4 nodupkey; by pairid treated gvkey ANNOUNCE_DATE ; run;

NOTE: There were 1826 observations read from the data set WORK.CAR_MEETINGDT4.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.CAR_MEETINGDT4 has 1826 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1369  
1370  data car_meetingdt5; set rawdata.car_meetingdt_capm_27_round2;
1371  rename car = car_meeting27;
1372  label car = "CAR[+2+7] Meeting dt";
1373  run;

NOTE: There were 1846 observations read from the data set RAWDATA.CAR_MEETINGDT_CAPM_27_ROUND2.
NOTE: The data set WORK.CAR_MEETINGDT5 has 1846 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1374  proc sort data=car_meetingdt5 nodupkey; by pairid treated gvkey ANNOUNCE_DATE ; run;

NOTE: There were 1846 observations read from the data set WORK.CAR_MEETINGDT5.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.CAR_MEETINGDT5 has 1846 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1375  
1376  data car_meetingdt6; set rawdata.car_meetingdt_capm_214;
1377  rename car = car_meeting214;
1378  label car = "CAR[+2+14] Meeting dt";
1379  run;

NOTE: There were 1826 observations read from the data set RAWDATA.CAR_MEETINGDT_CAPM_214.
NOTE: The data set WORK.CAR_MEETINGDT6 has 1826 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1380  proc sort data=car_meetingdt6 nodupkey; by pairid treated gvkey ANNOUNCE_DATE ; run;

NOTE: There were 1826 observations read from the data set WORK.CAR_MEETINGDT6.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.CAR_MEETINGDT6 has 1826 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1381  
1382  * compute the sum of Large and Small MFOR immediately before 13D;
1383  data mfor_13d; set rawdata.mfor_13d; run;

NOTE: There were 856 observations read from the data set RAWDATA.MFOR_13D.
NOTE: The data set WORK.MFOR_13D has 856 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1384  proc sort data=mfor_13d nodupkey; by gvkey CAMPAIGN_ID; run;

NOTE: There were 856 observations read from the data set WORK.MFOR_13D.
NOTE: 4 observations with duplicate key values were deleted.
NOTE: The data set WORK.MFOR_13D has 852 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

1385  
1386  
1387  * Investor Relation (IR) data;
1388  data ir;  set rawdata.ir2_022225_ext_pre; run;

NOTE: There were 90229 observations read from the data set RAWDATA.IR2_022225_EXT_PRE.
NOTE: The data set WORK.IR has 90229 observations and 32 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

1389  data ir_cp; set rawdata.ir2_022225_cp; run;

NOTE: There were 124238 observations read from the data set RAWDATA.IR2_022225_CP.
NOTE: The data set WORK.IR_CP has 124238 observations and 36 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

1390  data ir_cs; set rawdata.ir2_022225_cs; run;

NOTE: There were 21768 observations read from the data set RAWDATA.IR2_022225_CS.
NOTE: The data set WORK.IR_CS has 21768 observations and 36 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

1391  data ir_cpcs; set rawdata.ir2_022225_cpcs; run;

NOTE: There were 132403 observations read from the data set RAWDATA.IR2_022225_CPCS.
NOTE: The data set WORK.IR_CPCS has 132403 observations and 36 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      

1392  proc sql;
1393      create table ir as
1394      select  a.*,
1395              b.ir_dum as ir_dum_cp, b.ir_freq_adj_cp, b.ir_freq_adj_cp3, b.ir_freq_adj_cp5,
1395! b.ir_freq_adj_cp7,
1396              c.ir_dum as ir_dum_cs, c.ir_freq_adj_cs, c.ir_freq_adj_cs3, c.ir_freq_adj_cs5,
1396! c.ir_freq_adj_cs7,
1397              d.ir_dum as ir_dum_cpcs, d.ir_freq_adj_cpcs, d.ir_freq_adj_cpcs3,
1397! d.ir_freq_adj_cpcs5, d.ir_freq_adj_cpcs7, d.ir_freq as ir_freq_cpcs
1398      from ir as a left join ir_cp as b on a.gvkey=b.gvkey and a.qd=b.qd
1399      left join ir_cs as c on a.gvkey=c.gvkey and a.qd=c.qd
1400      left join ir_cpcs as d on a.gvkey=d.gvkey and a.qd=d.qd ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.IR created, with 90229 rows and 48 columns.

1401  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.20 seconds
      cpu time            0.21 seconds
      

1402  proc sort data=ir ; by gvkey year date; run;

NOTE: There were 90229 observations read from the data set WORK.IR.
NOTE: The data set WORK.IR has 90229 observations and 48 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      

1403  
1404  * experience level of proxy solicitors;
1405  data advisory; set rawdata.advisory; run;

NOTE: There were 9262 observations read from the data set RAWDATA.ADVISORY.
NOTE: The data set WORK.ADVISORY has 9262 observations and 12 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1406  proc sort data=advisory nodupkey; by CAMPAIGN_ID; run;

NOTE: There were 9262 observations read from the data set WORK.ADVISORY.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.ADVISORY has 9262 observations and 12 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1407  
1408  * Insider Ownership ;
1409  data insider; set rawdata.insider; run;

NOTE: There were 48632 observations read from the data set RAWDATA.INSIDER.
NOTE: The data set WORK.INSIDER has 48632 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1410  
1411  * Solicitor rank;
1412  data solicitor_rank; set rawdata.solicitor_rank; run;

NOTE: There were 2386 observations read from the data set RAWDATA.SOLICITOR_RANK.
NOTE: The data set WORK.SOLICITOR_RANK has 2386 observations and 17 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1413  proc sort nodupkey; by CAMPAIGN_ID; run;

NOTE: There were 2386 observations read from the data set WORK.SOLICITOR_RANK.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.SOLICITOR_RANK has 2386 observations and 17 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1414  
1415  * Voting Analytics data ;
1416  data vote;  set rawdata.npxvoteblock; run;

NOTE: There were 10948 observations read from the data set RAWDATA.NPXVOTEBLOCK.
NOTE: The data set WORK.VOTE has 10948 observations and 17 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

1417  proc sort data=vote nodupkey; by gvkey MeetingDate itemOnAgendaID; run;

NOTE: There were 10948 observations read from the data set WORK.VOTE.
NOTE: 756 observations with duplicate key values were deleted.
NOTE: The data set WORK.VOTE has 10192 observations and 17 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1418  
1419  * identify if a firm-family pair existed in the prior to the current (focal campaign);
1420  data has_prior_campaign;    set rawdata.has_prior_campaign; run;

NOTE: There were 2142 observations read from the data set RAWDATA.HAS_PRIOR_CAMPAIGN.
NOTE: The data set WORK.HAS_PRIOR_CAMPAIGN has 2142 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1421  
1422  * Merge datasets;
1423  proc sql;
1424      create table Analysis as
1425      select  a.*, b.*
1426      from    Analysis as a left join afc as b
1427      on      a.gvkey=b.gvkey and a.datadate = b.datadate ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
WARNING: Variable ryear already exists on file WORK.ANALYSIS.
WARNING: Variable datadate already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 364 columns.

1428  
1429      create table Analysis as
1430      select  a.*, b.insider_own
1431      from    Analysis as a left join insider as b
1432      on      a.gvkey=b.gvkey and a.datadate = b.datadate ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 365 columns.

1433  
1434      create table Analysis as
1435      select  a.*, b.aim, b.ln_oneplusaim, b.ln_aim
1436      from    Analysis as a left join aim as b
1437      on      a.gvkey=b.gvkey and a.datadate = b.datadate;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 368 columns.

1438  
1439      create table Analysis as
1440      select  a.*, b.psynch1,b.psynch2,b.psynch3,b.pinfo1,b.pinfo2,b.pinfo3
1441      from    Analysis as a left join psynch as b
1442      on      a.gvkey=b.gvkey and a.fyearq = b.fyear and a.fqtr=b.fqtr ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 374 columns.

1443  
1444      create table Analysis as
1445      select  a.*, b.*
1446      from    Analysis as a left join io_class as b
1447      on      a.gvkey=b.gvkey and a.fyearq=b.ryear and a.fqtr=b.rqtr ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
WARNING: Variable permno already exists on file WORK.ANALYSIS.
WARNING: Variable rdate already exists on file WORK.ANALYSIS.
WARNING: Variable ryear already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 383 columns.

1448  
1449      create table Analysis as
1450      select  a.*, b.kzindex,b.saindex,b.wwindex
1451      from    Analysis as a left join constraints as b
1452      on      a.gvkey=b.gvkey and a.fyearq=b.fyear+1  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 386 columns.

1453  
1454      create table Analysis as
1455      select  a.*, b.abvolume, b.volumeturn
1456      from    Analysis as a left join abvolume as b
1457      on      a.gvkey=b.gvkey and a.fyearq=b.fyearq and a.fqtr=b.fqtr;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 388 columns.

1458  
1459      create table Analysis as
1460      select  a.*, b.*
1461      from    Analysis as a left join retvol as b
1462      on      a.gvkey=b.gvkey and a.rdq=b.enddt;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 394 columns.

1463  
1464      create table Analysis as
1465      select  a.*, b.car_meeting00
1466      from    Analysis as a left join car_meetingdt1 as b
1467      on      a.gvkey=b.gvkey and a.pairid=b.pairid  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 395 columns.

1468  
1469      create table Analysis as
1470      select  a.*, b.car_meeting01
1471      from    Analysis as a left join car_meetingdt2 as b
1472      on      a.gvkey=b.gvkey and a.pairid=b.pairid  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 396 columns.

1473  
1474      create table Analysis as
1475      select  a.*, b.car_meeting11
1476      from    Analysis as a left join car_meetingdt3 as b
1477      on      a.gvkey=b.gvkey and a.pairid=b.pairid  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 397 columns.

1478  
1479      create table Analysis as
1480      select  a.*, b.car_meeting17
1481      from    Analysis as a left join car_meetingdt4 as b
1482      on      a.gvkey=b.gvkey and a.pairid=b.pairid  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 398 columns.

1483  
1484      create table Analysis as
1485      select  a.*, b.car_meeting27
1486      from    Analysis as a left join car_meetingdt5 as b
1487      on      a.gvkey=b.gvkey and a.pairid=b.pairid  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 399 columns.

1488  
1489      create table Analysis as
1490      select  a.*, b.car_meeting214
1491      from    Analysis as a left join car_meetingdt6 as b
1492      on      a.gvkey=b.gvkey and a.pairid=b.pairid  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 400 columns.

1493  
1494      create table Analysis as
1495      select  a.*, b.*
1496      from    Analysis as a left join AFERR as b
1497      on      a.gvkey=b.gvkey and
1498              year(a.datadate)=year(b.FPEDATS) ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 412 columns.

1499  
1500      create table Analysis as
1501      select  a.*, b.*
1502      from    Analysis as a left join mfor_13d as b
1503      on      a.gvkey=b.gvkey and a.CAMPAIGN_ID=b.CAMPAIGN_ID ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
WARNING: Variable campaign_id already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 33434 rows and 420 columns.

1504  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           8.31 seconds
      cpu time            9.37 seconds
      

1505  
1506  proc sql;
1507      create table Analysis as
1508      select  a.*,b.*
1509      from    Analysis as a join vote as b
1510      on      a.CAMPAIGN_ID = b.CAMPAIGN_ID  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
WARNING: Variable CAMPAIGN_ID already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 32032 rows and 435 columns.

1511  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.29 seconds
      cpu time            0.29 seconds
      

1512  proc sql;
1513      create table Analysis as
1514      select  a.*,b.has_prior_campaign
1515      from    Analysis as a left join has_prior_campaign as b
1516      on      a.gvkey=b.gvkey  and a.CAMPAIGN_ID = b.CAMPAIGN_ID  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 32032 rows and 436 columns.

1517  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.66 seconds
      cpu time            0.82 seconds
      

1518  
1519  * Construct the delta_InformedTrade variable;
1520  proc sql;
1521      create table Analysis1 as
1522      select *,
1523          avg(relstkpick1) as _relstkpick1,
1524          avg(stkpick1_Large) as _stkpick1_Large,
1525          avg(stkpick1_Small) as _stkpick1_Small
1526      from Analysis
1527      group by pairid, gvkey, post
1528      order by pairid, gvkey, qd ;
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Table WORK.ANALYSIS1 created, with 32032 rows and 439 columns.

1529  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.80 seconds
      cpu time            1.03 seconds
      

1530  
1531  data Analysis1;
1532      set Analysis1;
1533      if Post eq 0 then _relstkpick1_pre = _relstkpick1; else _relstkpick1_pre = . ;
1534      if Post eq 1 then _relstkpick1_pos = _relstkpick1; else _relstkpick1_pos = . ;
1535      if Post eq 0 then _stkpick1_large_pre = _stkpick1_Large; else _stkpick1_large_pre = . ;
1536      if Post eq 1 then _stkpick1_large_pos = _stkpick1_Large; else _stkpick1_large_pos = . ;
1537      if Post eq 0 then _stkpick1_small_pre = _stkpick1_Small; else _stkpick1_small_pre = . ;
1538      if Post eq 1 then _stkpick1_small_pos = _stkpick1_Small; else _stkpick1_small_pos = . ;
1539  run;

NOTE: There were 32032 observations read from the data set WORK.ANALYSIS1.
NOTE: The data set WORK.ANALYSIS1 has 32032 observations and 445 variables.
NOTE: DATA statement used (Total process time):
      real time           0.21 seconds
      cpu time            0.21 seconds
      

1540  
1541  proc sql;
1542      create table Analysis1 as
1543      select *,
1544          max(_relstkpick1_pre)    as relstkpick1_pre,
1545          max(_relstkpick1_pos)    as relstkpick1_pos,
1546          max(_stkpick1_large_pre) as stkpick1_large_pre,
1547          max(_stkpick1_large_pos) as stkpick1_large_pos,
1548          max(_stkpick1_small_pre) as stkpick1_small_pre,
1549          max(_stkpick1_small_pos) as stkpick1_small_pos
1550      from Analysis1
1551      group by cid, pairid, gvkey
1552      order by cid, pairid, gvkey, qd ;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS1 created, with 32032 rows and 451 columns.

1553  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.85 seconds
      cpu time            1.07 seconds
      

1554  
1555  %winsor(
1556      dsetin=work.Analysis1,
1557      dsetout=work.Analysis1,
1558      byvar=none,
1559      vars=relstkpick1_pos relstkpick1_pre stkpick1_large_pos stkpick1_large_pre
1559! stkpick1_small_pos stkpick1_small_pre ,
1560      type=winsor, pctl=1 99);

NOTE: There were 32032 observations read from the data set WORK.ANALYSIS1.
NOTE: The data set WORK.XTEMP has 32032 observations and 451 variables.
NOTE: DATA statement used (Total process time):
      real time           0.21 seconds
      cpu time            0.20 seconds
      


NOTE: There were 32032 observations read from the data set WORK.XTEMP.
NOTE: The data set WORK.XTEMP has 32032 observations and 452 variables.
NOTE: DATA statement used (Total process time):
      real time           0.22 seconds
      cpu time            0.21 seconds
      


NOTE: There were 32032 observations read from the data set WORK.XTEMP.
NOTE: The data set WORK.XTEMP has 32032 observations and 452 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.35 seconds
      cpu time            0.34 seconds
      


NOTE: The data set WORK.XTEMP_PCTL has 1 observations and 13 variables.
NOTE: PROCEDURE UNIVARIATE used (Total process time):
      real time           0.11 seconds
      cpu time            0.11 seconds
      


NOTE: There were 32032 observations read from the data set WORK.XTEMP.
NOTE: There were 1 observations read from the data set WORK.XTEMP_PCTL.
NOTE: The data set WORK.ANALYSIS1 has 32032 observations and 451 variables.
NOTE: DATA statement used (Total process time):
      real time           0.23 seconds
      cpu time            0.21 seconds
      

1561  
1562  data Analysis1;
1563      set Analysis1;
1564      d_relstkpick1    = relstkpick1_pos - relstkpick1_pre;
1565      d_stkpick1_large = stkpick1_large_pos - stkpick1_large_pre;
1566      d_stkpick1_small = stkpick1_small_pos - stkpick1_small_pre;
1567      drop relstkpick1_pos relstkpick1_pre _relstkpick1_pre _relstkpick1_pos _relstkpick1
1568          _stkpick1_large_pre _stkpick1_large_pos  stkpick1_large_pre  stkpick1_large_pos
1569          _stkpick1_small_pre _stkpick1_small_pos  stkpick1_small_pos  stkpick1_small_pre
1570          _stkpick1_Large _stkpick1_Small ;
1571  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      768 at 1564:40   768 at 1565:43   768 at 1566:43   
NOTE: There were 32032 observations read from the data set WORK.ANALYSIS1.
NOTE: The data set WORK.ANALYSIS1 has 32032 observations and 439 variables.
NOTE: DATA statement used (Total process time):
      real time           0.21 seconds
      cpu time            0.21 seconds
      

1572  
1573  data Analysis1;
1574      retain cid ANNOUNCE_DATE CAMPAIGN_ID gvkey treated MeetingDate ;
1575      set Analysis1;
1576      if EW_IOAfriend_diff ne . ;
1577      if VW_IOAfriend_diff ne . ;
1578      if d_relstkpick1 ne . ;
1579  run;

NOTE: There were 32032 observations read from the data set WORK.ANALYSIS1.
NOTE: The data set WORK.ANALYSIS1 has 31264 observations and 439 variables.
NOTE: DATA statement used (Total process time):
      real time           0.23 seconds
      cpu time            0.24 seconds
      

1580  
1581  * drop unwanted vars;
1582  data Analysis1 ;
1583      set Analysis1 ;
1584      drop outcome_desc company_fee_desc dissident_fee_desc dir_off_own_desc
1584! campaign_synopsis campaign_title iso_country
1585      targetname: targetfin: targetlegal: targetpr1 targetpr2 targetpr3  actfinanc: actlegal:
1585!  actpr: targetproxy2 targetproxy3 ;
1586  run;

NOTE: There were 31264 observations read from the data set WORK.ANALYSIS1.
NOTE: The data set WORK.ANALYSIS1 has 31264 observations and 397 variables.
NOTE: DATA statement used (Total process time):
      real time           0.13 seconds
      cpu time            0.12 seconds
      

1587  
1588  * Export data to Stata file;
1589  %let FFP =
1589! "C:\Users\hpham13\Projects\mf_activism\empirical\1_code\final_package_acceptance\assembledd
1589! ata_vote2_.dta";
1590  proc export data = Analysis1 outfile = &FFP. replace;
1590!                                                       run;

NOTE: The export data set has 31264 observations and 397 variables.
NOTE: "C:\Users\hpham13\Projects\mf_activism\empirical\1_code\final_package_acceptance\assembledd
      ata_vote2_.dta" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
      real time           0.11 seconds
      cpu time            0.12 seconds
      

1591  
1592  proc printto;
1593  run;

